package com.huawei.appmarket.support.audio;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;
import o.dky.d;
import o.evf;

public class AudioFrequencyView extends View {
    private c ʻ;
    private e ʼ = new e();
    private e ʽ = new e();
    private float ˊ;
    private Paint ˋ;
    private float ˎ;
    private int ˏ;
    private float ॱ;
    private e ॱॱ = new e();
    private float ᐝ;

    static class c implements Runnable {
        WeakReference<AudioFrequencyView> ˋ;

        public c(AudioFrequencyView audioFrequencyView) {
            this.ˋ = new WeakReference(audioFrequencyView);
        }

        public void run() {
            AudioFrequencyView audioFrequencyView = (AudioFrequencyView) this.ˋ.get();
            if (audioFrequencyView != null) {
                audioFrequencyView.postInvalidate();
                audioFrequencyView.postDelayed(this, 33);
            }
        }
    }

    static class e {
        private float ʻ;
        private float ʼ;
        private float ʽ;
        private float ˊ;
        private int ˋ;
        private float ˎ;
        private float ˏ;
        private float ॱ;
        private float ॱॱ;

        private e() {
        }

        public void ˏ() {
            this.ʼ += this.ʻ;
            if (ॱ()) {
                this.ʼ = this.ʽ;
                ˊ();
            }
        }

        public boolean ॱ() {
            if (this.ˋ != 1 || this.ʼ < this.ʽ) {
                return this.ˋ == -1 && this.ʼ <= this.ʽ;
            } else {
                return true;
            }
        }

        public void ˊ() {
            this.ˋ = -this.ˋ;
            float random = (float) ((Math.random() * 0.5d) + 0.5d);
            this.ॱॱ = this.ˋ == 1 ? random * (this.ˏ - this.ʽ) : random * (this.ˎ - this.ʽ);
            this.ʽ += this.ॱॱ;
            this.ʻ = (this.ॱॱ / (((float) ((Math.random() * 0.75d) + 0.25d)) * 500.0f)) * 33.0f;
        }

        public void ˋ(Canvas canvas, Paint paint) {
            ˏ();
            Canvas canvas2 = canvas;
            canvas2.drawLine((this.ॱ * 0.5f) + this.ˊ, this.ˏ, (this.ॱ * 0.5f) + this.ˊ, this.ʼ, paint);
        }

        public void ˎ(float f, float f2, float f3, float f4) {
            this.ˊ = f;
            this.ˎ = f2;
            this.ˏ = f4;
            this.ˋ = -1;
            this.ॱ = f3 - f;
            this.ʽ = f4;
            this.ʼ = f4;
            ˊ();
        }
    }

    public AudioFrequencyView(Context context) {
        super(context);
        ˎ(context);
    }

    public AudioFrequencyView(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        ˎ(context);
    }

    public AudioFrequencyView(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˎ(context);
    }

    public void ˎ(Context context) {
        this.ˋ = new Paint();
        this.ˋ.setAntiAlias(true);
        this.ʻ = new c(this);
        this.ˏ = evf.ॱ(context, d.ʻॱ);
    }

    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        this.ˎ = (float) getMeasuredWidth();
        this.ˊ = (float) getMeasuredHeight();
        this.ॱ = this.ˎ / ((float) 15);
        this.ᐝ = this.ॱ;
        float f = this.ˊ * 0.33333334f;
        float f2 = this.ˊ * 0.6666667f;
        float f3 = this.ˎ * 0.33333334f;
        float f4 = ((this.ˎ * 0.33333334f) + this.ॱ) + this.ᐝ;
        float f5 = ((this.ˎ * 0.33333334f) + (this.ॱ * 2.0f)) + (this.ᐝ * 2.0f);
        this.ʽ.ˎ(f3, f, this.ॱ + f3, f2);
        this.ʼ.ˎ(f4, f, this.ॱ + f4, f2);
        this.ॱॱ.ˎ(f5, f, this.ॱ + f5, f2);
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        this.ˋ.setColor(-16777216);
        this.ˋ.setAlpha(77);
        this.ˋ.setStyle(Style.FILL);
        this.ˋ.setStrokeWidth(0.0f);
        canvas.drawCircle(this.ˎ * 0.5f, this.ˊ * 0.5f, this.ˎ * 0.5f, this.ˋ);
        this.ˋ.setColor(this.ˏ);
        this.ˋ.setStrokeCap(Cap.ROUND);
        this.ˋ.setStrokeWidth(this.ॱ);
        this.ʽ.ˋ(canvas, this.ˋ);
        this.ʼ.ˋ(canvas, this.ˋ);
        this.ॱॱ.ˋ(canvas, this.ˋ);
    }

    public void ˋ() {
        removeCallbacks(this.ʻ);
        post(this.ʻ);
    }

    public void ˎ() {
        removeCallbacks(this.ʻ);
    }
}
